﻿@model System.Data.DataTable
@using CMSMVC4.MultiResource
@{
    ViewBag.Title = "Background";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<script language="javascript" type="text/javascript">
    function dellall() {
        var chek = $('#checkall').is(':checked');
        if (chek == true) {
            $(".checker span").attr('class', "checked");
            $(".dell").attr('checked', true);
        } else {
            $(".checker span").attr('class', "");
            $(".dell").attr('checked', false);

        }
    }
    function senddell() {
        var id = [];
        $(".dell:checked").each(function () {
            var v = $(this).attr("index");
            id.push(v);
        });
        if (id.length > 0) {
            var cf = confirm("Bạn có chắc chắn muốn xóa không?");
            if (cf == true) {
                $.ajax({
                    type: "Post",
                    dataType: "json",
                    contentType: 'application/json; charset=utf-8',
                    url: "/Admin/Background/Delete",
                    data: JSON.stringify(id),
                    success: function () {
                        window.location = "/Admin/Background";
                    }
                });
            }
        } else {
            alert("Hãy chọn bưu gửi muốn xóa!");
        }
    }
</script>
<div class="row-fluid">
    <div class="box color_11">
        <div class="title">
            <h4>
                <span>Background<small></small></span></h4>
        </div>
        <div class="content top">
            <table id="datatable_example" class="responsive table table-striped table-bordered"
                style="width: 100%">
                <thead>
                    <tr>
                        <th class="jv no_sort">
                            <label class="checkbox ">
                                <input type="checkbox" id="checkall" onchange="dellall()" />
                            </label>
                        </th>
                        <th class="" style="display: none">
                            ID
                        </th>
                        <th class="">@Admin.Images
                        </th>
                        <th class="">@Admin.Url
                        </th>
                        <th class="">
                            Active
                        </th>
                        <th class="">@Admin.Actions
                        </th>
                    </>
                </thead>
                <tbody>
                    @for (int i = 0; i < Model.Rows.Count; i++)
                    {
                        <tr>
                            <td>
                                @Html.CheckBox("status", new { @class = "dell", index = Model.Rows[i]["Id"] })
                            </td>
                            <td class="" style="display: none">
                                ID
                            </td>
                            <td class="">
                                <img src="@Model.Rows[i]["Name"]" alt="" style="height: 80px"/>
                            </td>
                            <td class="">@Model.Rows[i]["Name"]
                            </td>
                            @if (Model.Rows[i]["Status"].ToString() == CMSMVC4.Filters.CategoriStatus.Nhap.ToString())
                            {
                                <td class="">
                                    <a class="btn btn-small"  rel="tooltip" data-original-title="Set On" data-ajax="false" 
                                                data-ajax-method="Get" href="/Admin/Background/Active/@Model.Rows[i]["Id"]">
                                        Off</a>
                                </td>
                            }
                            else
                            {
                                <td class="">
                                    On
                                </td>
                            }
                            <td class="ms">
                                <a class="btn btn-small" onclick="senddell()"><i class="gicon-remove"></i></a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
<a class="btn btn-large btn-success" href="@Url.Action("Add", "Background")">Add Background</a>
<div id="boxes">
    <div id="dialog" style="overflow: auto">
    </div>
    <div id="dialog_nen">
    </div>
</div>
